<template>
  <div id="geSangQuan">
    <img
      src="https://tsyx-rights-and-interests.oss-cn-hangzhou.aliyuncs.com/ceshi/banner2.png"
      alt=""
      @click="toPosterNo2"
    />
    <img
      src="https://tsyx-rights-and-interests.oss-cn-hangzhou.aliyuncs.com/ceshi/youhui.png"
      alt=""
      @click="toCreatOrder"
    />
    <img
      src="https://tsyx-rights-and-interests.oss-cn-hangzhou.aliyuncs.com/img/cardRule.png"
      alt=""
      @click="toRoule"
    />
    <img
      src="https://tsyx-rights-and-interests.oss-cn-hangzhou.aliyuncs.com/ceshi/posterNo1.png"
      alt=""
    />
  </div>
</template>

<script>
import req from "@/utils/index";
import { Toast, Dialog } from "vant";
export default {
  data() {
    return {
      goodsNo: "",
      userMsg: {},
    };
  },
  methods: {
    toCreatOrder() {
      if (this.goodsNo == "") {
        Toast("网络连接超时，请稍后再试");
        this.getGeSangQuan();
        return;
      }
      window.localStorage.setItem("whatBuy", "water");
      this.$router.push({
        name: "creatOrder",
        query: {
          goodsNo: window.localStorage.getItem("geSangQuanGoodsNo"),
          didPay: "noYet",
        },
      });
    },
    toPosterNo2() {
      this.$router.push({ name: "posterNo2" });
    },
    getGeSangQuan() {
      // 获取格桑泉
      req("get", "/qyHome/getVipGoods?goodsType=1", {}).then((res) => {
        window.localStorage.setItem("geSangQuanGoodsNo", res);

        this.goodsNo = res.data;
      });
    },
    notVip() {
      Dialog.confirm({
        message: "您的手机号还不是平台的会员， 是否要成为会员？",
      })
        .then(() => {
          // on confirm
          window.localStorage.setItem("whatBuy", "gsqVip");
          this.$router.push({
            name: "creatOrder",
            query: {
              goodsNo: window.localStorage.getItem("VipGoodsNo"),
              didPay: "noYet",
              isGsq: true,
            },
          });
        })
        .catch(() => {
          // on cancel
        });
    },
    toRoule() {
      this.$router.push({
        name: "roule",
        query: {
          id: 2,
        },
      });
    },
  },
  created() {
    this.getGeSangQuan();
    this.userMsg = JSON.parse(window.localStorage.getItem("userMsg"));
  },
};
</script>

<style lang='scss' scoped>
#geSangQuan {
  text-align: center;
  img {
    width: 95%;
    margin-bottom: 0.3rem;
  }
}
</style>